package com.example.service;

import com.example.entity.DayHourChargeConfig;
import com.example.entity.ParkingRecord;
import com.example.strategy.ParkingFeeStrategy;

import java.math.BigDecimal;
import java.util.Optional;

public interface ParkingFeeService {

    BigDecimal calculateFee(ParkingRecord record, Long configId);

    default ParkingFeeStrategy getStrategy(DayHourChargeConfig config) {
        return Optional.ofNullable(config)
                .filter(c -> c.getHalfHourRate() != null)
                .map(c -> ParkingFeeStrategy.halfHourStrategy())
                .orElse(ParkingFeeStrategy.hourlyStrategy());
    }
}
